home *** CD-ROM | disk | FTP | other *** search
- Path: vb.franken.de!volker
- From: volker@vb.franken.de (Volker Barthelmann)
- Subject: Re: 680X0 -> PPC translator?
- Newsgroups: comp.sys.amiga.programmer
- References: <3143E4EB.7303@sapiens.com> <volker.0fsu@vb.franken.de> <31499F8E.26A9@netvision.net.il>
- X-Newsreader: TIN [AMIGA 1.3 950726BETA PL0]
- Message-ID: <volker.0fw1@vb.franken.de>
- Date: 18 Mar 96 23:11:42 MET
- Organization: home
-
- Jack (avilev@netvision.net.il) wrote:
- :
- : oh is that so?! unless you get the address from an outside source, such as allocating it YOU
- : must produce it, right?! so you have to have it stored somewhere in the program. if you get it
-
- No. I can get it from system functions or calculate it. And both possibilities
- can depend on information that is only available at runtime.
-
- : from some outside source, such as malloc(), then you don't have it obviously but that being said
- : doesn't imply it's impossible to figure out in which context the address is being used (ie code
- : or data) and make the proper modifications to the code. also bear in mind that all system
- : functions return pointers in either a0 or a1 and then that pointer is saved somewhere in memory
- : for later use, if the usage involves executing code in that part of memory then it's easy to
- ^^^^
- : trace the call to malloc() or what ever else and change the required size according to the
-
- Easy??
-
- : calculated code size, remember that the code is sitting somewhere inside your executable and
- : therefore its size is known, comparing this value to the values pushed to the stack before the
- : malloc() call and you would find the exact word address to change.
-
- You can't simply change all memory allocations of a certain size, because
- the program could use other chunks of memory that happen to have the same
- size.
- And in many programs You won't find any call to e.g. AllocMem with this
- size at all, because the program uses its own memory-pool-routines.
- Etc. etc...
-
- : > Easy said, but really doing this is a different story. First, You'll have to
- : > kind of disassemble the program and therefore You have to know what is data
- : > and what is code, but that's what You want to decide, so...
- : >
- : > Also doing this kind of analysis is pretty much impossible on Assembler code.
- : your mind is too cluttered with the complexity of things, but saying it isn't possible is simply
- : an unfounded claim.
-
- It's not unfounded, but I've thought about some things.
- There are much simpler similar problems that are AFAIK proven to be
- undecidable.
-
- : true things aren't that simple as with dynamic translation, but with a
- : little more effort they can be done, quite reliably too. and besides who says that dynamic
-
- What do You mean with 'quite reliably'? A translator that creates code
- that can be incorrect, but nobody knows when? This would be useless.
-
- : approach won't have the same difficulties as the static one, i can see the problem of
- : self-modifying code as not so easy to solve even in dynamic translation. that's because, as you
- : said what happens if the destination address was dynamically allocated, then you would have to
- : change its size again, wouldn't you?!
-
- I don't know much about dynamic compilation and didn't say anything about it.
- I'd guess those translators know when they have to fall back to
- interpretation.
-
- : > And a variable in memory in assembler looks like xyz(a7), but only at one
- : > point, because at another point it is xyz+c(a7). It is probably impossible
- : > to detect if they point to the same address.
- :
- : so what??? if you follow the changes made to a7, assuming an initial value of 0, you would
- : always know what address you're refering to right, doesn't matter how you try to disguise it,
- : and if you're keeping track of what is being done with that address location you can figure out
- : what the hell it is, either code or data.
-
- You can't simply 'keep track' of it, because there are loops and recursions
- in a program and if it does some more complicated things it's not possible
- to determine where e.g. a7 points to at a certain instruction, because this
- depends on the current iteration/recursion or other factors that can't be
- known before runtime.
-
- : you havn't obviously been listening to what i've said,
- : the translator isn't by any measure a stupid one, it must 'understand' the code it's translating
- ^^^^^^^^^^
- And this is simply not possible.
-
- : and make the proper modification to make it work. of course there will be exceptions to its
- : capablity cuz some assumptions are taken for granted, such as register usage etc, but for most
- : ansi-compliant programs, it will damn right be a very good tool and most compilers i know are
- : ansi-compliant.
-
- What do You mean by ansi-compliant programs and what does this have to do
- with it?
-
- : > Function addresses are often used in arithmetic calculations. Examples are
- : > copying of code or control-structures like in special switch-statements.
- : are you sure you're talking about functions and not just jump addresses, while similar they're
- : NOT the same thing. i'm talking about complete functions and their entry point is fixed and
- : therefore can't be calculated.
-
- Functions are components of certain high level languages. In machine language
- there are only addresses. Even if this code was generated by a compiler You
- have to keep track of any jump addresses to be able to determine the
- beginning and end of a function and what is code an what is data.
-
- Volker
-
- P.S.: Please don't use more than about 78 characters/line
-
-